{extend name="base:base" /}
{block name="body"}
<fieldset class="layui-elem-field layui-field-title mt-15">
    <legend>{present name="info"}编辑{else /}新增{/present}菜单</legend>
</fieldset>
<div class="layui-row">
    <div class="layui-col-xs12 layui-col-md6">
        <form class="layui-form" action="{:Url::build('renew')}" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" lay-verify="title" autocomplete="off"
                   placeholder="用于后台显示的配置标题" value="{$info.title ?? ''}"
                   class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="text" name="sort" placeholder="用于分组显示的顺序" lay-verify="required|number"
                   class="layui-input" value="{$info.sort ?? 0}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">链接</label>
        <div class="layui-input-block">
            <input type="text" name="url" lay-verify="required" placeholder="函数解析的URL或者外链，支持带http://的URL或U函数参数格式"
                   autocomplete="off" value="{$info.url|default=''}" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">上级菜单</label>
        <div class="layui-input-block">
            {notempty name='menus'}
                <select name="pid">
                    {volist name="menus" id="menu"}
                        <option value="{$menu.id}">{$menu.title_show|raw}</option>
                    {/volist}
                </select>
            {/notempty}
        <div class="layui-form-mid layui-word-aux">所属的上级菜单</div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">分组</label>
        <div class="layui-input-block">
            <input type="text" name="group" lay-verify="title" autocomplete="off" value="{$info.group ?? ''}" class="layui-input">
            <div class="layui-form-mid layui-word-aux">用于左侧分组二级菜单</div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">是否隐藏</label>
        <div class="layui-input-block">
            <input type="radio" name="hide" value="1" title="是" >
            <input type="radio" name="hide" value="0" title="否" checked>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">仅开发者模式可见</label>
        <div class="layui-input-block">
            <input type="radio" name="is_dev" value="1" title="是" >
            <input type="radio" name="is_dev" value="0" title="否" checked>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">说明</label>
        <div class="layui-input-block">
            <textarea placeholder="菜单详细说明" name="tip" rows="4" class="layui-textarea">{$info.tip ?? ''}</textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="menu">立即提交</button>
            <button  class="layui-btn layui-btn-primary retreat">取消</button>
        </div>
    </div>
</form>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    UrlHighlight("{:Url::build('Menu/index')}");
    setChoose("pid", "{$pid ?: 0}");
    //监听提交
    layui.use(['jquery', 'form', 'layer'], function () {
        layui.form.on('submit(menu)', function (data) {
            layui.$.post(data.form.action, data.field, function (info) {
                status_load(info, data.elem);
            })
            return false;
        });
    })
</script>
{/block}